package com.zhuang.interpreter;

/**
 * @Classname Plus
 * @Description 非终结符表达式角色 加法表达式
 * @Date 2021/3/31 9:46
 * @Created by dell
 */

public class Plus extends AbstractExpression {

    private AbstractExpression left;
    private AbstractExpression right;

    public Plus(AbstractExpression left, AbstractExpression right) {
        this.left = left;
        this.right = right;
    }

    @Override
    public int interpret(Context context) {
        return left.interpret(context) + right.interpret(context);
    }

    @Override
    public String toString() {
        return "(" + left.toString() + " + " + right.toString() + ")";
    }
}
